package leetcode_acm.array;

import org.junit.Test;

import java.util.Arrays;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月21日 19:08
 */
public class UniqueOccurrences {
    public boolean uniqueOccurrences(int[] arr) {
        if(arr == null || arr.length == 0){
            return true;
        }
        int[] freq = new int[2000+5];
        for (int i = 0; i < arr.length; i++) {
            freq[arr[i]+1000]++;
        }
        int[] memo = new int[1000+5];
        for (int i = 0; i < freq.length; i++) {
            if(freq[i] != 0 && memo[freq[i]] != 0){
                return false;
            }else if(freq[i] != 0 && memo[i] == 0){
                memo[freq[i]] = 1;
            }
        }
        return true;
    }
    @Test
    public void test(){
        System.out.println(uniqueOccurrences(new int[]{1,2}));
    }
}
